package com.dx.springbootwebservice.endpoint;

import com.dx.springbootwebservice.ws.Country;
import com.dx.springbootwebservice.ws.Currency;
import com.dx.springbootwebservice.ws.GetCountryRequest;
import com.dx.springbootwebservice.ws.GetCountryResponse;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;



/**
 * @author: dx
 * @date: 2019/3/26/0026
 * @description:
 */
@Endpoint
public class CountryEndpoint {
	private static final String NAMESPACE_URI = "http://www.springbootwebservice.dx.com/ws";
	@PayloadRoot(namespace = NAMESPACE_URI, localPart = "getCountryRequest")
	@ResponsePayload
	public GetCountryResponse getCountry(@RequestPayload GetCountryRequest request) {
		GetCountryResponse response = new GetCountryResponse();
		Country poland = new Country();
		poland.setName("Poland-" + request.getName());
		poland.setCapital("Warsaw");
		poland.setCurrency(Currency.PLN);
		poland.setPopulation(38186860);
		response.setCountry(poland);
		return response;
	}
}
